from time import sleep

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

s = Service(r"./chromedriver.exe")
bro = webdriver.Chrome(service=s)

bro.get("https://www.taobao.com/")
input_element = bro.find_element(By.XPATH, '//*[@id="q"]')
input_element.send_keys('Iphone')

bro.execute_script('window.scrollTo(0,document.body.scrollHeight)')
sleep(2)

btn_element = bro.find_element(By.XPATH, '//*[@id="J_TSearchForm"]/div[1]/button')
btn_element.click()

bro.get('https://www.baidu.com')
sleep(2)
bro.back()
sleep(2)
bro.forward()

sleep(5)
bro.quit()
